/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.ucase.casemain.controller;

import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.StrUtil;
import com.icinfo.cloud.common.core.page.PageResponse;
import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.*;
import com.icinfo.cloud.provider.punish.ucase.casemain.service.ICaseProsecutionService;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseInfoQueryVo;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseProsecutionJudgmentVo;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseProsecutionRegisterVo;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseProsecutionVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 描述:  案件诉讼控制器
 *
 * @author lilihao
 * @date 2022年12月01日
 */
@RestController
@RefreshScope
@RequestMapping("/punish/ucase/prosecution")
@Slf4j
public class CaseProsecutionController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(CaseProsecutionController.class);

    @Autowired
    private ICaseProsecutionService caseProsecutionService;

    /**
     * 分页获取案件诉讼列表
     *
     * @param request 请求对象
     * @return 诉讼列表
     * @author lilihao
     * @date 2022/12/2 20:39
     */
    @PostMapping("/getPageList")
    @ApiOperation(value = "【V1.9.3】描述：分页获取案件诉讼列表", httpMethod = "POST")
    public Result<PageResponse<CaseProsecutionVo>> getPageList(@RequestBody @Validated CaseProsecutionPageQueryRequest request) {
        PageResponse<CaseProsecutionVo> pageList = caseProsecutionService.getPageList(request);
        return Result.success(Constant.STRING_GET_SUCCESS, pageList);
    }

    /**
     * 获取案件诉讼详情
     *
     * @param idDto 请求对象
     * @return 案件诉讼详情
     * @author lilihao
     * @date 2022/12/2 20:39
     */
    @PostMapping("/getDetail")
    @ApiOperation(value = "【V1.9.3】描述：获取案件诉讼详情", httpMethod = "POST")
    public Result<Dict> getDetail(@RequestBody @Validated CaseProsecutionIdDto idDto) {
        Dict detail = caseProsecutionService.getDetail(idDto);
        return Result.success(Constant.STRING_GET_SUCCESS, detail);
    }

    /**
     * 获取关联案件列表
     *
     * @param queryNameDto 请求对象
     * @return 关联案件列表
     * @author lilihao
     * @date 2022/12/2 20:39
     */
    @PostMapping("/getRelCaseList")
    @ApiOperation(value = "【V1.9.3】描述：获取关联案件列表", httpMethod = "POST")
    public Result<List<CaseInfoQueryVo>> getRelCaseList(@RequestBody @Validated CaseInfoQueryNameDto queryNameDto) {
        List<CaseInfoQueryVo> relCaseList = caseProsecutionService.getRelCaseList(queryNameDto);
        return Result.success(Constant.STRING_GET_SUCCESS, relCaseList);
    }

    /**
     * 获取诉讼登记信息
     *
     * @param idDto 请求对象
     * @return 诉讼登记信息
     * @author lilihao
     * @date 2022/12/2 20:39
     */
    @PostMapping("/getRegisterInfo")
    @ApiOperation(value = "【V1.9.3】描述：获取诉讼登记信息", httpMethod = "POST")
    public Result<CaseProsecutionRegisterVo> getRegisterInfo(@RequestBody @Validated CaseProsecutionIdDto idDto) {
        CaseProsecutionRegisterVo registerInfo = caseProsecutionService.getRegisterInfo(idDto);
        return Result.success(Constant.STRING_GET_SUCCESS, registerInfo);
    }

    /**
     * 保存诉讼登记信息
     *
     * @param registerSaveDto 请求对象
     * @return 诉讼登记信息
     * @author lilihao
     * @date 2022/12/2 20:39
     */
    @PostMapping("/saveRegisterInfo")
    @ApiOperation(value = "【V1.9.3】描述：保存诉讼登记信息", httpMethod = "POST")
    public Result saveRegisterInfo(@RequestBody @Validated CaseProsecutionRegisterSaveDto registerSaveDto) {
        if (StrUtil.isBlank(registerSaveDto.getId())) {
            //新增
            caseProsecutionService.saveRegisterInfo(registerSaveDto);
        } else {
            //修改
            caseProsecutionService.updateRegisterInfo(registerSaveDto);
        }
        return Result.success(Constant.STRING_SAVE_SUCCESS);
    }

    /**
     * 删除诉讼信息
     *
     * @param idDto 请求对象
     * @return 返回对象
     * @author lilihao
     * @date 2022/12/2 20:39
     */
    @PostMapping("/delInfo")
    @ApiOperation(value = "【V1.9.3】描述：删除诉讼信息", httpMethod = "POST")
    public Result delInfo(@RequestBody @Validated CaseProsecutionIdDto idDto) {
        caseProsecutionService.delInfo(idDto);
        return Result.success(Constant.STRING_SUCCESS_CH);
    }

    /**
     * 获取诉讼判决信息
     *
     * @param idDto 请求对象
     * @return 返回对象
     * @author lilihao
     * @date 2022/12/2 20:39
     */
    @PostMapping("/getJudgmentInfo")
    @ApiOperation(value = "【V1.9.3】描述：获取诉讼判决信息", httpMethod = "POST")
    public Result<CaseProsecutionJudgmentVo> getJudgmentInfo(@RequestBody @Validated CaseProsecutionIdDto idDto) {
        CaseProsecutionJudgmentVo judgmentInfo = caseProsecutionService.getJudgmentInfo(idDto);
        return Result.success(Constant.STRING_GET_SUCCESS, judgmentInfo);
    }

    /**
     * 保存诉讼判决信息
     *
     * @param saveDto 请求对象
     * @return 返回对象
     * @author lilihao
     * @date 2022/12/2 20:39
     */
    @PostMapping("/saveJudgmentInfo")
    @ApiOperation(value = "【V1.9.3】描述：保存诉讼判决信息", httpMethod = "POST")
    public Result saveJudgmentInfo(@RequestBody @Validated CaseProsecutionJudgmentSaveDto saveDto) {
        caseProsecutionService.saveJudgmentInfo(saveDto);
        return Result.success(Constant.STRING_SAVE_SUCCESS);
    }

    /**
     * 是否拥有法制人员角色
     *
     * @return 返回对象
     * @author lilihao
     * @date 2022/12/2 20:39
     */
    @PostMapping("/isHaveLawRole")
    @ApiOperation(value = "【V1.9.3】描述：是否拥有法制人员角色", httpMethod = "POST")
    public Result isHaveLawRole() {
        return Result.success(Constant.STRING_GET_SUCCESS, caseProsecutionService.isHaveLawRole());
    }

}